package com.musichord.core.unit.chord;


public class Chord implements Cloneable {
	private int root;
	private int standardPitch;
	private int duration;
	private PitchPattern pitchPattern;
	public PitchPattern getPitchPattern() {
		return pitchPattern;
	}

	public void setPitchPattern(PitchPattern pitchPattern) {
		this.pitchPattern = pitchPattern;
	}

	private TexturePattern texturePattern;


	public Chord(int root, int duration, PitchPattern pitchPattern,
			TexturePattern texturePattern) {
		this.root = root % 12;
		standardPitch = 36; // Default
		this.duration = duration;
		this.pitchPattern = pitchPattern;
		this.texturePattern = texturePattern;
	}

	

	public int getRoot() {
		return root;
	}

	public int getDuration() {
		return duration;
	}

	public TexturePattern getTexturePattern() {
		return texturePattern;
	}

	public int getLowestPitch() {
		int low_in_pattern = this.pitchPattern.getPitches()[0] + root;
		return low_in_pattern + standardPitch;
	}

	public Chord Transpose(int pitch_offset) {
		int root_offset = pitch_offset % 12;
		int octave_offset = pitch_offset - root_offset;
		root += root_offset;
		standardPitch += octave_offset;
		return this;
	}

	public Chord OctaveUp() {
		return Transpose(12);
	}

	public Chord OctaveDown() {
		return Transpose(-12);
	}

	public Chord clone() {
		Chord clone = new Chord(root, duration, pitchPattern, texturePattern);
		return clone;
	}

	public int getStandardPitch() {
		return standardPitch;
	}

	public void setStandardPitch(int standard_pitch) {
		standardPitch = standard_pitch;
	}
}
